package main.java.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.concurrent.ThreadPoolExecutor;
import main.java.task.TimePrintTask;

@Service
public class TaskService {

    @Autowired
    private ThreadPoolExecutor threadPoolExecutor;

    public void startTask() {
        // 提交任务到线程池执行
        threadPoolExecutor.execute(new TimePrintTask());
    }

    public void shutdownThreadPool() {
        // 关闭线程池
        threadPoolExecutor.shutdown();
    }
}